namespace AdminSG3L.Applicaticn.ServicesInterface;

using AdminSG3L.Domain.Entities;
using AdminSG3L.Applicaticn.Commands;
using AdminSG3L.Applicaticn.Dtos;

/// <summary>
/// 权限服务接口，定义权限相关的应用层操作
/// </summary>
public interface IPermissionService
{
    /// <summary>
    /// 创建新权限
    /// </summary>
    Task<ApiResponse<PermissionDto>> CreateAsync(CreatePermissionDto dto);

    /// <summary>
    /// 批量添加权限
    /// </summary>
    Task<ApiResponse<IEnumerable<PermissionDto>>> BatchCreateAsync(IEnumerable<CreatePermissionDto> dtos);

    /// <summary>
    /// 更新权限信息
    /// </summary>
    Task<ApiResponse<bool>> UpdateAsync(UpdatePermissionDto dto);

    /// <summary>
    /// 删除权限
    /// </summary>
    Task<ApiResponse<bool>> DeleteAsync(Guid id);

    /// <summary>
    /// 级联删除权限（包括所有子权限）
    /// </summary>
    Task<ApiResponse<int>> DeleteCascadeAsync(Guid id);

    /// <summary>
    /// 批量删除权限
    /// </summary>
    Task<ApiResponse<int>> BatchDeleteAsync(IEnumerable<Guid> ids);

    /// <summary>
    /// 查询所有权限
    /// </summary>
    Task<ApiResponse<IEnumerable<PermissionDto>>> GetAllDtoAsync();

    /// <summary>
    /// 分页查询权限
    /// </summary>
    Task<ApiResponse<(IEnumerable<PermissionDto> Permissions, int TotalCount)>> GetPagedDtoAsync(int pageIndex, int pageSize);

    /// <summary>
    /// 分页查询权限（支持筛选）
    /// </summary>
    Task<ApiResponse<(IEnumerable<PermissionDto> Permissions, int TotalCount)>> GetPagedDtoAsync(int pageIndex, int pageSize, PermissionFilterDto? filter = null);

    /// <summary>
    /// 获取权限总数
    /// </summary>
    Task<ApiResponse<int>> GetCountAsync();

    /// <summary>
    /// 条件查询单个权限
    /// </summary>
    Task<ApiResponse<PermissionDto?>> FindOneAsync(Func<PermissionDto, bool> predicate);

    /// <summary>
    /// 条件查询多个权限
    /// </summary>
    Task<ApiResponse<IEnumerable<PermissionDto>>> FindManyAsync(Func<PermissionDto, bool> predicate);

    /// <summary>
    /// 给权限分配角色
    /// </summary>
    Task<ApiResponse<bool>> AssignRoleAsync(Guid permissionId, Guid roleId);

    /// <summary>
    /// 移除权限角色
    /// </summary>
    Task<ApiResponse<bool>> RemoveRoleAsync(Guid permissionId, Guid roleId);

    /// <summary>
    /// 修改权限启用状态
    /// </summary>
    Task<ApiResponse<bool>> SetEnabledAsync(Guid permissionId, bool enabled);

    Task<ApiResponse<PermissionDto?>> GetDtoByIdAsync(Guid id);

    /// <summary>
    /// 获取顶级权限分组（用于筛选下拉框）
    /// </summary>
    Task<ApiResponse<IEnumerable<PermissionDto>>> GetTopLevelPermissionsAsync();
} 